﻿using DryIoc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace DryIocDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new SomeClient(new GreetService());
            client.Service.Greeting("World");

            var container = new Container();
            container.Register<IClient, SomeClient>();
            container.Register<IService, GreetService>();

            var iocClient = container.Resolve<IClient>();
            iocClient.Service.Greeting("Michael");


            var assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies();
            foreach (var assembly in assemblies)
            {
                Console.WriteLine(assembly.FullName);
            }
        }
    }

    public interface IService
    {
        void Greeting(string message);
    }

    public class GreetService : IService
    {
        public void Greeting(string message)
        {
            Console.WriteLine($"Hello,{message}");
        }
    }

    public interface IClient
    {
        IService Service { get; }
    }

    public class SomeClient : IClient
    {
        public IService Service { get; }

        public SomeClient(IService service)
        {
            this.Service = service;
        }
    }
}
